1. Field of the Present Invention
The present invention generally relates to computer graphics and more particularly to a circuit that calculates sphere mode texture coordinates as part of a geometry processing device in a graphics adapter.
2. History of Related Art
Graphics display subsystems are almost universally encountered in microprocessor based computer systems to facilitate a variety of graphics tasks and applications including computer assisted drafting, architectural design, simulation trainers for aircraft and other vehicles, molecular modeling, virtual reality applications, and video games. Graphics processors, graphics adapters, and a variety of similarly designed computer products provide specialized hardware to speed the execution of graphics instructions and rendering of graphic images. These processors and adapters typically include, for example, circuitry optimized for translating, rotating, and scaling 3D graphic images. In a typical application, a graphical image that is displayed on a display terminal or other output device is composed of one or more graphic primitives. For purposes of this disclosure, a graphic primitive may be thought of as one or more points, lines, or polygons that are associated with one another, such as by being connected to one another. Typically, the displayed image is generated by creating one or more graphic primitives, assigning various attributes to the graphic primitives, defining a viewing point and a viewing volume, determining which of the graphic primitives are within the defined viewing volume, and rendering those graphic primitives as they would appear from the viewing point. This process can require a tremendous amount of computing power to keep pace with the ever increasingly complex graphics applications that are commercially available. Accordingly, designers of graphics systems and graphics applications are continuously seeking cost effective means for improving the efficiency at which graphic images are rendered and displayed.
Typically a software application program generates a 3D graphics scene, and provides the scene, along with lighting attributes, to an application programming interface (API) such as the OpenGL(copyright) API developed by Silicon Graphics, Inc. Complete documentation of OpenGL(copyright) is available in M. Woo et al., OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 1.2 (Addison Wesley Longman, Inc. 1999) and D. Schreiner, OpenGL Reference Manual, Third Edition: The Official Reference Document to OpenGL, Version 1.2 (Addison Wesley Longman, Inc. 1999), both of which are incorporated by reference herein.
A 3D graphics scene typically includes of a number of polygons that are delimited by sets of vertices. The vertices are combined to form larger primitives, such as triangles or other polygons. The triangles (or polygons) are combined to form surfaces, and the surfaces are combined to form objects. Each vertex is associated with a set of attributes. Vertex attributes may include a position, including three Cartesian coordinates x, y, and z, a material color, which describes the color of the object to which the vertex belongs, and a normal vector, which describes the direction to which the surface is facing at the vertex. Each light source has a number of properties associated with it, including a direction, an ambient color, a diffuse color, and a specular color.
Rendering is employed within the graphics system to create two-dimensional image projections of a 3D graphics scene for display on a monitor or other display device. Typically, rendering includes processing geometric primitives (e.g., points, lines, and polygons) by performing one or more of the following operations as needed: transformation, clipping, culling, lighting, fog calculation, and texture coordinate generation. Rendering further includes processing the primitives to determine component pixel values for the display device, a process often referred to specifically as rasterization.
The OpenGL(copyright) API specification and other API""s such as the DirectX(copyright) API define the allowed vertex and scene attributes and the equations used to determine attribute values. In a Each vertex may also be associated with texture coordinates and/or an alpha (transparency) value. In addition, the scene itself may be associated with a set of attributes including, as examples, an ambient color that typically describes the amount of ambient light and one or more individual light sources, conventional graphics adapter, the calculations specified by a particular API are implemented in software. It will be appreciated that software calculations can adversely affect the performance of the graphics adapter, especially if the equations require complex, floating point calculations. It would therefore be desirable to implement, to the extent feasible, some or all of the calculations specified by a particular graphics API in dedicated hardware circuitry. Moreover, it would be desirable if the implemented solution balanced improved performance against cost by optimizing the hardware design to account for such factors as, the frequency with which the particular function or equation is invoked and the speed required of the particular equation.
OpenGL(copyright) specifies the manner in which environmental mapped texture coordinates (also referred to a sphere mode texture coordinates or, simply, sphere coordinates) are determined. It would desirable to implement the calculation of sphere mode coordinates in a dedicated hardware circuit that utilizes sufficient resources to perform the sphere mode coordinate calculations in significantly less time than required to perform the same calculation in software while not unnecessarily increasing the cost or size of the graphics adapter.
The problem identified above is addressed by a sphere mode texture coordinate generation circuit as disclosed herein for use in a graphics adapter of a data processing system. The circuit includes a set of input multiplexers configured to receive x, y, and z components of a normal vector and a unit vector corresponding to the current vertex. The circuit further includes a set of functional units such as a floating point multiplier, a floating point adder, a floating point compare-to-zero unit, and an inverse square unit. The functional units are configured to receive outputs from the set of multiplexer and are enabled to perform floating point operations on the outputs of the set of multiplexers. A controller or state machine of the circuit is enabled to determine the state of select inputs to each of the set of multiplexers. The controller manages the multiplexer select inputs such that the circuit determines sphere mode texture coordinates in response to receiving the normal vector and the unit vector. The circuit typically includes a set of latches, where the input of each of the latches is connected to an output of a corresponding input multiplexer. The circuit may include an S Out multiplexer and a T Out multiplexer, where the output of S Out multiplexer represents the S sphere mode texture coordinate and the output of the T Out multiplexer represents the T sphere mode texture coordinate calculated in compliance with a predetermined specification such as the OpenGL(copyright) specification.